﻿
using Mapster;
using MediatR;
using Order.Application.Orders.Commands.DeleteOrder;

namespace Order.API.Endpoints
{
    public record DeleteOrderRequest(Guid Id);
    public record DeleteOrderResponse(bool Success);
    public class DeleteOrder : ICarterModule
    {
        public void AddRoutes(IEndpointRouteBuilder app)
        {
            app.MapDelete("/api/orders/{Id}", async (DeleteOrderRequest request,ISender sender) =>
            {
                var command=request.Adapt<DeleteOrderCommand>();
                var result=await sender.Send(command);
                var response=request.Adapt<DeleteOrderResponse>();
                return Results.Ok(response);

            }).WithName("DeleteOrder")
        .Produces<DeleteOrderResponse>(StatusCodes.Status200OK)
        .ProducesProblem(StatusCodes.Status400BadRequest)
        .ProducesProblem(StatusCodes.Status404NotFound)
        .WithSummary("Delete Order")
        .WithDescription("Delete Order");
        }
    }
}
